// ////////////////////////////////////////////////////////////////////////////////////////
// NAME: CommandLine.java 
// AUTHOR: CDT Riley Mckenna 
// LAST MODIFIED: 28 March 2012 
// DESCRIPTION: Contains code for primitive version of RootTools. Under Development.
// LIMITATIONS: 
// CITATIONS: In code
// 
// ////////////////////////////////////////////////////////////////////////////////////////
package prototype.revision;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class CommandLine {
	private Runtime rt;
	private Process proc; // sets the users to root
	private BufferedReader buffer;
	private String fin = "";

	public String exec(String command) {
		try {
			rt = Runtime.getRuntime();
			proc = rt.exec(command);
			InputStream input = proc.getInputStream();
			InputStreamReader reader = new InputStreamReader(input);
			buffer = new BufferedReader(reader);
			String str = buffer.readLine();
			fin = str;
		} catch (Throwable t) {
			// TODO Auto-generated catch block
			t.printStackTrace();
		}
		return fin;
	}

	String catFile(String the_file) {
		String file_contents = "";

		file_contents = exec("cat " + the_file);

		return file_contents;
	}

	public BufferedReader getBuffer() {
		return buffer;
	}
}
